#pragma once
#include "core/types.h"
#include "core/inlineFuncs.h"

class Fps
{
public:
	Fps(void): frameCount(0), lastCalcTime(0),fps(0){}
	~Fps(void){}

	void RegisterFrame(const uint &now);

	String ToString() const;
public:
	uint	frameCount;
	uint	lastCalcTime;
	uint 	fps;
};

inline void Fps::RegisterFrame(const uint &now)
{
	frameCount++;
	 static uint elapse = 0;
	 elapse = now - lastCalcTime;
	if (elapse > 1500)
	{
		fps = 1000 * frameCount / elapse;
		frameCount = 0;
		lastCalcTime = now;
	}
}

inline String Fps::ToString() const
{
	return Convert<String>(fps);
}



